package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsStudyTrain;
import com.ruoyi.system.domain.news.query.NewsStudyTrainQuery;
import com.ruoyi.system.domain.news.vo.NewsStudyTrainVo;
import com.ruoyi.system.domain.news.vo.NewsStudyTrainVo;
import com.ruoyi.system.mapper.news.NewsStudyTrainMapper;
import com.ruoyi.system.service.news.NewsStudyTrainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsStudyTrainServiceImpl extends ServiceImpl<NewsStudyTrainMapper, NewsStudyTrain>
        implements NewsStudyTrainService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsStudyTrainVo> getNewsStudyTrainList(NewsStudyTrainQuery newsStudyTrainQuery) {
        if (newsStudyTrainQuery.getIfPage()) {
            PageHelper.startPage(newsStudyTrainQuery.getPageNum(), newsStudyTrainQuery.getPageSize());
        }
        List<NewsStudyTrainVo> newsStudyTrainVoList = baseMapper.getNewsStudyTrainList(newsStudyTrainQuery);
        if (!newsStudyTrainVoList.isEmpty() && newsStudyTrainQuery.getId() == null) {
            for (NewsStudyTrainVo newsStudyTrainVo:newsStudyTrainVoList) {
                newsStudyTrainVo.setContent(null);
            }
        }
        return newsStudyTrainVoList;
    }
}
